import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
export const columns: BasicColumn[] = [
  {
    title: '参数名称',
    dataIndex: 'configName',
    width: 120,
  },
  {
    title: '参数键名',
    dataIndex: 'configKey',
    width: 100,
  },
  {
    title: '参数键值',
    dataIndex: 'configValue',
    width: 120,
  },
  {
    title: '系统参数',
    dataIndex: 'isSys',
    width: 60,
    customRender: ({ text }) => {
      const color = text == '1' ? 'green' : 'gray';
      const value = text == '1' ? '是' : '否';
      return render.renderTag(value, color);
      //return render.renderTag(render.renderDict(text, 'notify_send_status'), color);
    },
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    label: '参数名称',
    field: 'configName',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '参数键名',
    field: 'configKey',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    field: 'isSys',
    label: '系统参数',
    component: 'Select',
    componentProps: {
      options: [
        { label: '请选择...', value: '' },
        { label: '是', value: '1' },
        { label: '否', value: '0' },
      ],
    },
    colProps: { span: 6 },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    label: '参数名称',
    field: 'configName',
    required: true,
    component: 'Input',
    dynamicDisabled: ({ values }) => {
      return !!values.id;
    },
  },
  {
    label: '参数键名',
    field: 'configKey',
    required: true,
    component: 'Input',
  },
  {
    label: '参数键值',
    field: 'configValue',
    component: 'Input',
    required: true,
  },
  {
    label: '系统参数',
    field: 'isSys',
    component: 'Switch',
    defaultValue: '0',
    componentProps: {
      checkedValue: '1',
      checkedChildren: '是',
      unCheckedValue: '0',
      unCheckedChildren: '否',
    },
  },
  {
    label: '参数描述',
    field: 'remarks',
    component: 'InputTextArea',
    componentProps: {
      rows: 4,
    },
  },
];
